<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>列举对象相关信息</title>
<c:import url="/page/common/scripts.jsp"></c:import>
<script type="text/javascript">

	$(function(){
		//添加对象，保存更新对象
		$("#dictObjectList a[title='添加对象']").bind("click",function(){
			var $addObjectDiv=$("#addObjectDiv");
			if($addObjectDiv.length==0){
				$addObjectDiv=$("<div></div>").attr("id","addObjectDiv").appendTo("body");
			}
			$.ajax({
				"url":"common.editDictObject.do",
				"dataType":"html",
				"success":function(data){
					$addObjectDiv.html(data);
				}
			});
		});
		
		$("#dictObjectList a[title='查看对象属性']").click(function(){
			var addId=$(this).data("add-id")+"";
			commonObject.getObjectFieldInfoList('objectFieldsList','common.listAllObjectField.do',{
				"idObject":addId
			});
		});
		
		$("#addObjectDiv form").live('submit',function(){
			var b=true;
			$("input[name^='dictObject']").each(function(i,ele){
				if($(ele).val()==""||$(ele).val()=="undefined"){
					var content=$(ele).closest("tr").children("th:first").text()+"不能为空！";
					$(ele).append(content);
					b=false;
				}
			});
			if(!b){
				return false;
			}
			var $data=$(this).serializeArray();
			$.ajax({
				"url":"common.updateObject.do",
				"dataType":"html",
				"data":$data,
				"success":function(result){
					$("#dictObjectList").html(result);
				}
			});
		}); 
		
		$("#objectFieldsList a[title='添加']").live('click',function(){
			var idObject=$(this).attr("data-add-idObject")+"";
			commonObject.getObjectFieldInfoList('editObjetOrField','common.editDictObjectField.do',{
				"idObject":idObject
			});
		});
		$("#editObjetOrField a[title='保存']").live('click',function(){
			var dictObject2field=$(this).attr("data-save-dictObject2field")+"";
			var idObject=$(this).attr("data-save-idObject")+"";
			if(dictObject2field==""){
				dictObject2field=null;
			}
			if(idObject==""){
				idObject=null;
			}
			//href="javascript:commonObject.saveField('editObjetOrField','','${idObject}');"
			commonObject.saveField('editObjetOrField',dictObject2field,idObject);
		});
	});
</script>
</head>
<body>
	<div id="dictObjectList">
		<table border="1">
		<tr>
			<th colspan="4" style="text-align: left;">对象相关信息表</th>
			<td><a href="javascript:;" title="添加对象">添加</a></td>
		</tr>
		<tr>
			<th>对象名</th>
			<th>界面名称</th>
			<th>表空间</th>
			<th>备注</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${dictObjectList }" var="dictObject">
			<tr>
				<td>${dictObject.sobjectName }</td>
				<td>${dictObject.suiName }</td>
				<td>
				<a href="javascript:;" title="查看对象属性" data-add-id="${dictObject.id }">
				${dictObject.stableName }
				</a>
				</td>
				<td>${dictObject.snote }</td>
				<td>
					编辑
				</td>
			</tr>
		</c:forEach>
	</table>
	</div>
	
	<div id="objectFieldsList">
		
	</div>
</body>
</html>